package com.jerry.lifecyclemonitor;

public interface TaskLifecycle<T> {
    //线程开始执行时
    void onStart(Thread thread);

    //线程执行中
    void onRunning(Thread thread);

    //线程执行完成
    void onFinish(Thread thread, T result);

    //线程执行异常
    void onError(Thread thread, Exception e);

    //默认生命周期实现
    class EmptyTaskLifecycle<T> implements TaskLifecycle<T> {
        @Override
        public void onStart(Thread thread) {

        }

        @Override
        public void onRunning(Thread thread) {

        }

        @Override
        public void onFinish(Thread thread, T result) {

        }

        @Override
        public void onError(Thread thread, Exception e) {

        }
    }

}
